
    <table class="table">
        <thead>
            <tr>
              
                <td style='width:150px;'>参数名称</td>
                <td>参数值 <small>拖动行可进行排序</small></td>
	 <th style='width:50px;'></th>
            </tr>
        </thead>
        <tbody id="param-items">
            {loop $params $p}
            <tr>
               
                <td>
                      {ife 'goods' $item}
                    <input name="param_title[]" type="text" class="form-control param_title" value="{$p['title']}"/>
                    {else}
                      {$p['title']}
                    {/if}
                    <input name="param_id[]" type="hidden" class="form-control" value="{$p['id']}"/>
                </td>
                <td>
                       {ife 'goods' $item}
                    <input name="param_value[]" type="text" class="form-control param_value" value="{$p['value']}"/>
                {else}   {$p['value']}
                    {/if}
                </td>
	<td>
                   {ife 'goods' $item}
                    <a href="javascript:;" class='btn btn-default btn-sm' onclick="deleteParam(this)" title="删除"><i class='fa fa-remove'></i></a>
                    {/if}
                </td>
            </tr>
            {/loop}
        </tbody>
           {ife 'goods' $item}
        <tbody>
            <tr>
                
                <td colspan="3">
                    <a href="javascript:;" id='add-param' onclick="addParam()" class="btn btn-default"  title="添加参数"><i class='fa fa-plus'></i> 添加参数</a>
                </td>
            </tr>
        </tbody>
        {/if}
    </table>
 

<script language="javascript">
    $(function() {
	require(['jquery.ui'],function(){
	  $("#param-items").sortable();
    });
        $("#chkoption").click(function() {
            var obj = $(this);
            if (obj.get(0).checked) {
                $("#tboption").show();
                $(".trp").hide();
            }
            else {
                $("#tboption").hide();
                $(".trp").show();
            }
        });
    })
    function addParam() {
        var url = "{php echo merchUrl('goods/tpl',array('tpl'=>'param'))}";
//        return false;
        $.ajax({
            "url": url,
            success: function(data) {
                $('#param-items').append(data);
            }
        });
        return;
    }
    function deleteParam(o) {
        $(o).parent().parent().remove();
    }
</script>